<dependency> <groupId>org.gatein</groupId> <artifactId>cdi-portlet-integration</artifactId> <version>1.0.0.Final</version> </dependency>
There are a couple of steps to enabling CDI for JSF2 portlets that use Portlet Bridge.
First is to add the following dependency to your pom.xml to add the portlet integration library for CDI:
<dependency> <groupId>org.gatein</groupId> <artifactId>cdi-portlet-integration</artifactId> <version>1.0.0.Final</version> </dependency>
When deploying to GateIn, the portlet integration library for CDI is automatically included for JSF2 portlets that use CDI.
So we need to ensure the dependency is marked as provided in our pom.xml:
<dependency> <groupId>org.gatein</groupId> <artifactId>cdi-portlet-integration</artifactId> <version>1.0.0.Final</version> <scope>provided</scope> </dependency>
Add the following portlet filter definition into your portlet.xml:
<filter> <filter-name>PortletCDIFilter</filter-name> <filter-class>org.gatein.cdi.PortletCDIFilter</filter-class> <lifecycle>ACTION_PHASE</lifecycle> <lifecycle>EVENT_PHASE</lifecycle> <lifecycle>RENDER_PHASE</lifecycle> <lifecycle>RESOURCE_PHASE</lifecycle> </filter>
Then add to portlet.xml the activation of the above filter for each portlet that requires CDI:
<filter-mapping> <filter-name>PortletCDIFilter</filter-name> <portlet-name>[Name of your portlet as defined in portlet-name]</portlet-name> </filter-mapping>